#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include "cathread.h"
#include "caevent.h"
int es_thread_start(pthread_t *tid, void *(*thread_proc)(void* user), void *user, es_t* psys)
{
	int ret;
	if(psys)
		memset(psys, 0, sizeof(es_t));
	ret = pthread_create(tid, NULL, thread_proc, user);		
	if(psys)
		es_ready(psys);
	return ret;
}

void es_thread_stop(pthread_t tid)
{
	pthread_join(tid, NULL);
}
